package com.controller.admin;

import com.service.admin.AdminWalletService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**  */
@RestController
@CrossOrigin
public class AdminWalletController {
  @Autowired AdminWalletService adminWalletService;

  /**
   * 获取用户的钱包流水记录条数，total,waitDeal
   *
   * @return 钱包流水记录条数，total,waitDeal
   */
  @PostMapping("admin/getWithdrawRecordCount")
  public Map<String, Integer> getWithdrawRecordCount() {
    return adminWalletService.getWithdrawRecordCount();
  }
  /**
   * 获取提现记录
   *
   * @param userId 用户编号,可空
   * @param deal 0 全部，1是已处理，-1是未处理
   * @param pageSize 页大小
   * @param pageIndex 页索引
   * @return 提现记录
   */
  @PostMapping("admin/getWithdrawalRecord")
  public List<Map<String, Object>> getWithdrawalRecord(
      String userId, @RequestParam("deal") int deal, Integer pageSize, Integer pageIndex) {
    return adminWalletService.getWithdrawalRecord(userId, deal, pageSize, pageIndex);
  }

  /**
   * 处理提现请求，更新用户的账户书币，并添加通知
   *
   * @param id 记录编号
   * @param adminName 管理员名
   * @param file 截图
   * @return 1/0
   */
  @PostMapping("admin/dealWithDraw")
  public String dealWithDraw(
      @RequestParam("id") int id,
      @RequestParam("adminName") String adminName,
      @RequestParam("image") MultipartFile file) {
    int ret = adminWalletService.dealWithDraw(id, adminName, file);
    return String.valueOf(ret);
  }
}
